'use strict';

import React from 'react';
import {
  Dimensions,
  Image,
  InteractionManager,
  View,
  Text,
  Platform,
  StatusBar,
} from 'react-native';

import Main_Tab from './Main_Tab';

var {height, width} = Dimensions.get('window');

class Splash extends React.Component {
  constructor(props) {
    super(props);
  }
  componentDidMount() {
      const {navigator} = this.props;
      if(Platform.OS == 'ios'){
          InteractionManager.runAfterInteractions(() => {
              navigator.resetTo({
                  component: Main_Tab,
                  name: 'Main_Tab'
              });
          });
      }else{
          this.timer=setTimeout(() => {
              InteractionManager.runAfterInteractions(() => {
                  navigator.resetTo({
                      component: Main_Tab,
                      name: 'Main_Tab'
                  });
              });
          }, 1000);
      }

  }
  componentWillUnmount() {
    this.timer && clearTimeout(this.timer);
  }

  isShowWelcom(){
     if(Platform.OS == 'ios'){
        return null;
     }
     return(
         <View
           style={{flex:1,width:width,height:height,alignItems:'center',justifyContent:'center'}}
         >
             <Text style={{fontSize:18}}>欢迎来到微微购</Text>
         </View>
     )
  }

  render() {
    return (
      <View style={{flex:1}}>
        <StatusBar hidden={true}/>
        {this.isShowWelcom()}
      </View>
    );
  }
}
export default Splash;
